<?php

namespace app\admin\controller;

use app\common\mongo\MongoDb;
use app\model\AdminModel;
use think\App;
use think\Request;

class Admin extends Base
{
    public function __construct(Request $app)
    {
        parent::__construct($app);
        $this->model = AdminModel::class;
    }


    public function queryWhere()
    {
        if(!empty($this->param['admin_name'])){
            $this->param['admin_name'] = ['like','%'.$this->param['admin_name'].'%'];
        }
        return parent::queryWhere();
    }

    public function beforeUpdate($param, $id)
    {
        if($param['password_1'] != $param['password']){
            $param['password'] = md5($param['password']);
        }
        unset($param['password_1']);
        return parent::beforeUpdate($param, $id); // TODO: Change the autogenerated stub
    }
}